Xcode 4 Cookbook by unknow

Xcode 4 Cookbook by unknow

Author:unknow
Language: eng
Format: epub
Publisher: Packt Publishing


The following screenshot shows our snippet document existing within our application's container within iCloud:

Note

The previous screen can be accessed using the Settings application and then navigating to Settings | iCloud | Storage & Backup | Manage Storage.

How it works...

In this recipe, we learned how to build and create the user interface for our iCloudExample application to store and retrieve documents within iCloud. We then created the outlet properties for each of our buttons to have the ability of saving and loading the document when pressed. In our next step, we create a UIDocument subclass and declare an NSString property variable docContent that will be used to store the contents of our document when it gets created or modified. We then proceed to synthesize our document content property so that our class can access those objects associated with it. We then proceed to override the loadFromContents: method to read the data from the file into our UIDocument subclass. The most important parameter to note here is contents; this is an NSData object containing the actual data that was entered when you created or updated your document model.

The background queue NSFilePresenter calls this method whenever a read operation has completed. If the document was saved without entering any data, we assign a default value of empty string. We then proceed to override the contentsForType: method that is used when the background queue of the NSFilePresenter requests a snapshot of the contents of the UIDocument subclass. Here we check to ensure that the document contains contents, and if so, we convert our documents data to an NSData object, and return this as an NSData instance. Next, we declare our Snippet object that will be used to hold the document that gets created, as well as our NSMetadataQuery object that will be used to query and look up the document within our application's iCloud repository and access the relevant object properties of each file. In our next steps, we first check to ensure that we can access our application's iCloud repository, and then proceed to set the background color and font name and size for our docContents control, before finally calling the reload: method to pull the document from our iCloud repository.

We then proceed to register an observer object to enable us to periodically check for changes in document state using the UIDocumentStateChangedNotification notification object. Next, we declare our btnSave: method and set up an ubiq variable to point to our document container within our iCloud account. We then use the ubiquitousPackage class, and then append our filename to the location of the iCloud documents container. We then initialize our UIDocument class document with some default contents and then use the UIDocumentSaveForCreating property of our forSaveOperation method to create a brand new document.

For the btnLoad: method, we start by ensuring that we can connect it to the iCloud data store, and then set up and initialize our docQuery query predicate to look for our document using the predicate class method NSMetadataQueryUbiquitousDocumentScope and then set



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(56077)
What's Done in Darkness by Kayla Perrin(26615)
The Fifty Shades Trilogy & Grey by E L James(19095)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19079)
Shot Through the Heart by Mercy Celeste(18952)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(17131)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(17019)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(16894)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16840)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16467)
The Subtle Art of Not Giving a F*ck by Mark Manson(14382)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14157)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13669)
Scorched Earth by Nick Kyme(12785)
Drei Generationen auf dem Jakobsweg by Stein Pia(10980)
Suna by Ziefle Pia(10902)
Scythe by Neal Shusterman(10366)
The Ultimate Python Exercise Book: 700 Practical Exercises for Beginners with Quiz Questions by Copy(10216)
De Souza H. Master the Age of Artificial Intelligences. The Basic Guide...2024 by Unknown(10176)
D:\Jan\FTP\HOL\Work\Alien Breed - Tower Assault CD32 Alien Breed II - The Horror Continues Manual 1.jpg by PDFCreator(10173)